This is a basic example of run-length encoding; there are many schemes to reduce file size by eliminating redundancy.