Probably you didn't open the file in binary mode when writing and/or reading the pickled data. In this case newline format conversion will occur, which can break the binary data.
To open a file in binary mode you have to provide "b" as part of the mode string: