Python 3 compatibility fixes for the test suite.

These changes will allow "make check" to run as long as the python binary is at least version 2.6, including python 3.