Python 3 Support

Updates PR #224, with fixed tests.