Allow specifying output. Closes #1
Refactoring as requested by @bgentry