Fix decoding of layer data.

InflaterInputStream uses a buffer during read. When it gets to the end of
the buffered data during a bulk read, it will not buffer more data until
the next read, so it is not guaranteed that the full 4 bytes will be read
in one read operation. Attempt to read more bytes until we get our 4
bytes, or until we hit the end of the stream.