improve python3 compatibility