The method is Interpreter>>writeImageFileIO:. �Here's the relevant extract from the slightly extended method in Cog:
headerSize := 64. �"header size in bytes; do not change!"
f := self cCode: 'sqImageFileOpen(imageName, "wb")'.
f = nil ifTrue: "could not open the image file for writing"
[^self primitiveFail].
headerStart := self cCode: 'sqImageFileStartLocation(f,imageName,headerSize+imageBytes)'.
self cCode: '/* Note: on Unix systems one could put an exec command here, padded to 512 bytes */'.
"position file to start of header"
self sqImageFile: f Seek: headerStart.
self putLong: self imageFormatVersion toFile: f.
self putLong: headerSize toFile: f.
self putLong: imageBytes toFile: f.
self putLong: self startOfMemory toFile: f.
self putLong: specialObjectsOop toFile: f.
self putLong: self newObjectHash toFile: f.
self putLong: self ioScreenSize toFile: f.
self putLong: self getImageHeaderFlags toFile: f.
self putLong: extraVMMemory toFile: f.
self putShort: desiredNumStackPages toFile: f.
self putShort: self unknownShortOrCodeSizeInKs toFile: f.
self putLong: desiredEdenBytes toFile: f.
self putShort: (maxExtSemTabSizeSet ifTrue: [self ioGetMaxExtSemTableSize] ifFalse: [0]) toFile: f.
self putShort: 0 toFile: f.
1 to: 4 do: [:i | self putLong: 0 toFile: f]. �"fill remaining header words with zeros"
So the simple header (the header without an initial 512 bytes used on some Mac systems) looks like:
bytes �0 to �3: image version number in either little or big endian order (used to determine header and image byte order)
6504 for 32-bit images
68002 for 64-bit images
6505 for 32-bit Cog images (slightly different compact class layout)
bytes �4 to �7: header size (e.g. 64 bytes)
bytes �8 to 11: image size in bytes
bytes 12 to 15: address of start of first object in image (nil) when image was saved (*)
bytes 16 to 19: address of specialObjectsOop (not start of specialObjectsOop) when�image was saved (*)
bytes 20 to 23: next object hash (unused in Cog)
bytes 24 to 27: screen width << 16 + screen height
big endian: bytes 24 & 25 are width, little endian: bytes 24 & 25 are height
bytes 28 to 31: image flags, conventional VMs use only bit 0, Cog also uses bits 1 through 4
bit 0: 1 => open full screen, 0 => open using width & height