Fixed a couple of Python 3 compatibility issues