encode output data to python bytes