Python 3 compatibility: When converting from str to bytearray, use the 'ascii' encoding