Fix all py3 compatibility problems.