LZW: prevent reading beyond the end of the stream

Fixes #10525.
Merge pull request #419 from melissalinkert/10525

LZW: prevent reading beyond the end of the stream