Python 3 compatibility

Allows the code to be run on Python 3 as well as Python 2