LZW implementation