Python 3 support

This pull request implements nominal Python 3 support. Doctests pass. Please consider making a release with these changes.