Export formats and better option parsing

This branch 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.