Handle basestring in python3