fix py3 compatibility issues