Python 3 compatibility: PY_TYPE
Python 3 compatibility: PyInt -> PyLong
Python 3 compatibility: write callback
Python 3 compatibility: whitespace changes
remaining changes - more acceptable
remaining changes - less acceptable