fixed py3 compatibility issues.