Fix: don't modify fileSize and frameCount in header when writing it