code: DataOutputStream writeHeaderAndWrapStream(OutputStream os)
    throws IOException {
      DataOutputStream dos = new DataOutputStream(os);
  
      dos.writeBoolean(imageCodec != null);
  
      if (imageCodec != null) {
        String codecClassName = imageCodec.getClass().getCanonicalName();
        Text.writeString(dos, codecClassName);
  
        return new DataOutputStream(imageCodec.createOutputStream(os));
      } else {
        // use a buffered output stream
        return new DataOutputStream(new BufferedOutputStream(os));
      }
    }
docs: Write out a header to the given stream that indicates the chosen
  compression codec, and return the same stream wrapped with that codec.
  If no codec is specified, simply adds buffering to the stream, so that
  the returned stream is always buffered.
  
  @param os The stream to write header to and wrap. This stream should
  be unbuffered.
  @return A stream wrapped with the specified compressor, or buffering
  if compression is not enabled.
  @throws IOException if an IO error occurs or the compressor cannot be
  instantiated