fix Python3 compatibility issues