Use one write with heredocs and move to the with statement as per PEP343

This takes the multiline writes and `with` cleanups from #75 as mentioned in the last comment.

To answer the question when `with` was added then PEP343 (http://www.python.org/dev/peps/pep-0343/) describes the `with` keyword and was added to Python 2.5 (http://effbot.org/zone/python-with-statement.htm) as a future statement and moved into normal namespace in 2.6 (http://docs.python.org/2/whatsnew/2.6.html#pep-343-the-with-statement)

So depending on how far back you want to support Python versions?

Additionally I changed all the `f` variables to `handle` after pylint complained at me but then I realised I hadn't loaded the oz pylint config - Do you want me to fix it all back to `f`?

Took longer than I thought to get this going, sorry for the delay.