iMZ320/ZPL: How to use Z64 and LZ77 to compress data downloading to the printer

Hi, I have an iMZ320 8cm printer and I want to use it with Android devices. Usually we transform all our print data to graphics and send them to the printer; this works in our case (using ^GF for every graphics field), but it needs too much time to download all the data. Currently I use ASCII encoding with Base64 (for example: "^GFA,1152,1152,72,:B64:AAADwAAAA+AAA<.....>AAA:f113") So I thought to use compression. There is the possibility of LZ77 compression before the Base64 encoding (something like that: "^GFA,1152,1152,75,:Z64:xxxxxx:crcc").

Can anybody assist me how to implement the LZ77 algorithm? Thanks in advance.