First attempt at py2/py3 compability in the C API.