It's shameless self-promotion, but my startup Leanpub (http://leanpub.com) lets you write in HTML or Markdown, embed external code samples, save your files in Dropbox and produce PDF, EPUB and MOBI with one click. We sell all 3 formats, with automatic update distribution to existing readers when you publish a new version (so you can sell your book while it's in progress). You keep the rights to your book, etc.