While not end of file
Read next block of data into buffer and
enter all pairs in hash table with counts of their occurrence
While compression possible
Find most frequent byte pair
Replace pair with an unused byte
If substitution deletes a pair from buffer,
decrease its count in the hash table
If substitution adds a new pair to the buffer,
increase its count in the hash table
Add pair to pair table
End while
Write pair table and packed data
End while