basestring should be replaced with str for python 3
More python3 compatibility
Fix encoding of subprocess results
Fix encoding for another subprocess call