Adjustments for Python 3 compatibility.
Add python 3 support