Added python3 support

I converted the existing python module to a python 3 compatible one.
The result passes pep8 validation (apart from line length).