Fixes for Python 3.3 compatibility, while retaining Python 2.7 compatibility