Python3 Support

- added Python 3 support, without breaking Python 2
- PEP 8 style fixes
- cleanups