PEP8 compliance

Python code should be formatted according to [PEP8](http://legacy.python.org/dev/peps/pep-0008/). This PR is formatting the existing code accordingly through the use of [autopep8](https://github.com/hhatto/autopep8) and some additional manual formatting.