Fix basestring check to work with both 2.x and 3

basestring was removed in Python 3 and all strings now inherit from unicode, I've added a workaround to set basestring to unicode if it's not available.