Python 3 compatibility

Allows the code to be run on Python 3 as well as Python 2
Merge pull request #1 from Portadiam/master

Python 3 compatibility (from Portadiam)