f = open('./put/your/path/here.png', 'wb') # wb stand for "write byte" on the file f.write(data) f.close()