Unknown Error Message

I keep getting the following error message

FAIL: exotic error
‘utf-8’ codec can’t decode byte 0xff in position 13: invalid start byte

please help me decipher this. I realise it is somehow related to my write_to_image_file function

thank you. I figured it out.