Python 3 compatibility using six.string_types instead of basestring