Fix support for Python 3

Closes #144.