Port to python 3

These changes will make pycco work in python 3.