Improve python3 compatibility