Allow output format to be specified
Move writers to separate module
Add a basic test for writers