Fix corrupted encoding and improve compression

Fixes a bug causing corrupted QR codes, and adds a sorts-of-compression using chunked encoding.