Recompression isn't hard. It's just tedious.
Search the preceding data for any match between 2 bytes and $11 (17 dec) long that's less than $1000 bytes back from the current position. Once you've found the longest possible match, calculate the compression code and output it, or else output the plaintext code. Track the compression flags for each code, and once you've got a full byte, output that. (Note that you'll need to do things backwards - you have to write the compression flag byte which goes before the codes after you've calculated them.)