Export formats and better option parsing

This pull request includes two major changes:

* Better option parsing using Python's optparse module. This offers better error handling, much shorter and cleaner code, builtin -h flag, and eases the addition of new features.
* Support for three export formats: plain, html, and json.

I also did a small cleanup, removing commented code and fixing spacing a few places.