Python3 compatibility

The code should work under both Python2 and Python3. This will solve issue #16