Fix Python 3 problems

The tests currently fail with Python 3 interpreters. These changes fix that.