Style Fixes

This pull request fixes general code readability problems. In addition it also fixes the incorrect handling of py3 files. Python 3 allows you to use the following code construct to automagically close files for you, even in the event of errors:

```
with open(<file>, <mode>) as <var>:
    # do stuff with var
# var has been var.close'd here
```