         if !isOpaque {
             tag_count += 1
         }
+        
+        var data = MappedBuffer<UInt8>(fileBacked: true)
+        data.encode(TIFFHeader(endianness: .BIG, version: 42, IFD: 8))
         
         data.encode(tag_count.bigEndian)
         encode(tag: .SamplesPerPixel, type: 3, value: [samplesPerPixel], &data)

    
    static func encode(image: AnyImage, properties: [ImageRep.PropertyKey : Any]) -> Data? {
        
        var data = MappedBuffer<UInt8>(fileBacked: true)
        data.encode(TIFFHeader(endianness: .BIG, version: 42, IFD: 8))
        
        let isOpaque = image.isOpaque
        let samplesPerPixel = isOpaque ? image.colorSpace.numberOfComponents : image.colorSpace.numberOfComponents + 1
        

            bitsPerChannel = 16
            
            if photometric == 8 {
                if let image = image.base as? Image<ColorPixel<LabColorModel>>, image.colorSpace == .cieLab(white: Point(x: 0.34567, y: 0.35850)) {
                    pixelData = rawData(image, isOpaque)
                } else {
                    pixelData = rawData(Image<FloatColorPixel<LabColorModel>>(image: image, colorSpace: .cieLab(white: Point(x: 0.34567, y: 0.35850))), isOpaque)
                }
            } else {
                let image = image.base as! TIFFRawRepresentable
