Support for multiple formats

I've added support for multiple formats (e.g. JSON), added argument parsing, and improved exception handling a little bit.