The problem is the file(xxx).read(). That is opening the file in text mode, not binary mode. The read is finding a ^Z, which is end of file. The difference between binary and text mode is one of the silliest things that MS ever did.
Use something like
Code:
handle = open(filename, 'rb')
content = handle.read()
handle.close()