Added compatibility fixes for python3.x