I can't tell what your program does, and you didn't say what it's supposed to do either. At least in any detail. But I do notice that you're converting bytes to chars a lot, and then converting them back to bytes by writing them to an output stream.
Your comments say something about "ASCII characters" but
Java doesn't limit itself to ASCII. Java characters are two-byte things that represent UNICODE characters, and converting a character to a byte doesn't just drop the leading byte. Instead it does a conversion that assumes the character is text, which is likely to be an incorrect assumption for compressed data. If a char isn't represented in your system's default character set, then converting it to bytes results in '?'.
So: don't use chars, use bytes. I know that will require some changes because you can't just use
String concatenation to collect bytes together, but chars are wrong here.