For upstream

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