Port to Python 3

Here's my shot at porting the code to Python 3 using 2to3, to address Issue #117