How to overwrite some bytes in the middle of a file with Python?
According to this python page you can type file.seek to seek to a particualar offset. You can then write whatever you want.
To avoid truncating the file, you can open it with "a+" then seek to the right offset.