Hey! I've become curious to how exactly TPT encodes stamps in .stm files and what the data means. Feel free to get techincal since I already have some experience in working with raw data of encodings! (mainly .ogg files)
12 bytes of header data. This contains save format version, tpt version, width / height info and the size of the save.
After that, it's bz2-compressed bson data. bson is basically a binary form of json, in a way. We store a lot of misc properties in here, then a few maps (like air maps, wall maps), and finally the particle data map.
The particle data map is most complex, it saves particles from top to bottom, left to right, saving every particle in each position. For each particle, it stores a list of flags that say what properties to load. So for example, there would be a flag saying "load one byte of .life". This lets it save space only saving the info it needs.