Replace references to unicode and basestring
Update imports for Python 3

2to3 fixer imports (+ manual changes)