With x86 programs, there is especially a lot of runs of 0. We should optimize the format used on the blockchain by using a very simple run length encoding system. With this, only the byte 0 would be affected by this, as other values are too random to benefit.
Basic psuedo code:
Loop through bytedata
if data is 0 and the next data is also 0, then error.
If data is 0, then write 0 next data times, and then advance data to next value.
Otherwise, write data.
Advance data to next value
Because there is already size fields in the binary stream, no dynamic allocations are needed and this should require only one cheap scan through the data.