Made .encodes conditional, in case someone explicitly passes bytes in Python 3