Html postprocessor

- Fixed Query.write to support file-like objects opened for appending
- Moved HTML/Javascript code to HTML template