tiff/lzw: don't follow code == hi if last is invalid

This does for x/image what
https://go-review.googlesource.com/c/go/+/45111/ did for the standard
library's compress/lzw.

The x variant is a fork of the stdlib, with an extra, explicit tweak
because the TIFF format is "off by one" - a mistake (not Go specific)
somebody introduced decades ago and that we can never fix, given all the
existing TIFF files out there in the wild.

When previously patching the stdlib variant, I was supposed to also
patch the x variant, but forgot.

Updates golang/go#11386

Change-Id: Ic74f9014d2d048ee12cdd151332db62b76f1cde2
Reviewed-on: https://go-review.googlesource.com/c/image/+/191221
Reviewed-by: Bryan C. Mills <bcmills@google.com>
diff --git a/tiff/lzw/reader.go b/tiff/lzw/reader.go
index 51ae39f..78204ba 100644
--- a/tiff/lzw/reader.go
+++ b/tiff/lzw/reader.go
@@ -178,7 +178,7 @@
 			break loop
 		case code <= d.hi:
 			c, i := code, len(d.output)-1
-			if code == d.hi {
+			if code == d.hi && d.last != decoderInvalidCode {
 				// code == hi is a special case which expands to the last expansion
 				// followed by the head of the last expansion. To find the head, we walk
 				// the prefix chain until we find a literal code.