in case of python2, force str type to be converted to bytes