Pass bytes to NamedTemporaryFile.write()

In Python 3, this function takes bytes as an input.

Change-Id: I45faa50c4796605885489c9003a1b23b0f0b3080
Merge "Pass bytes to NamedTemporaryFile.write()"