Custom query result formatting

This adds interfaces for query output formatting. And provides implementations for writing into files, with custom format specified. 
formatter.commit is done once all the writes succeed. In the FileFormatter, we are moving the formatted temporary file to final location, which is available for consumption. So, commit should not be called in finally. close is for closing freeup any resources that are used. That should be moved to finally.