Python 3 support

I've ported this to python 3. Tested using nosetests as README suggested, and passed all tests for both python 2 and 3.