Py3 compatibility fixes

* Fixed inconsistent use of tabs and spaces in indentation
* Urllib2 no longer exists, migrated to urllib.request
* Fixed imports