Improve py3 compatibility