Fixed inconsistent use of tabs and spaces in indentation
Python 3 compatibility fixes