Some compatibility fixes for Python 3.