         if WebPValidateConfig(&config) == 0 {
             fatalError("invalid config")
         }
-        
+
         var picture = WebPPicture()
         if WebPPictureInit(&picture) == 0 {
             fatalError("version error")
         }
-        
-        picture.use_argb = 1
+
+        picture.use_argb = config.lossless == 0 ? 0 : 1
         picture.width = Int32(originWidth)
         picture.height = Int32(originHeight)
-        
+
         if WebPPictureAlloc(&picture) == 0 {
             fatalError("memory error")
         }
-        
+
         let ok = importer(&picture, dataPtr, Int32(stride))
         if ok == 0 {
             WebPPictureFree(&picture)
             fatalError("can't import picture")
         }
-        
+
         if resizeHeight > 0 && resizeHeight > 0 {
             if (WebPPictureRescale(&picture, Int32(resizeWidth), Int32(resizeHeight)) == 0) {
                 fatalError("can't rescale picture")
             }
         }
-        
+
         var buffer = WebPMemoryWriter()
         WebPMemoryWriterInit(&buffer)
         let writeWebP: @convention(c) (UnsafePointer<UInt8>?, Int, UnsafePointer<WebPPicture>?) -> Int32 = { (data, size, picture) -> Int32 in

        }
        picture.writer = writeWebP
        picture.custom_ptr = UnsafeMutableRawPointer(&buffer)
        
        if WebPEncode(&config, &picture) == 0 {
            WebPPictureFree(&picture)


        }
        return try encode(RGBA, importer: importer, config: config, originWidth: originWidth, originHeight: originHeight, stride: stride)
    }

    public func encode(RGBX: UnsafeMutablePointer<UInt8>, config: WebPEncoderConfig,
                       originWidth: Int, originHeight: Int, stride: Int,
                       resizeWidth: Int = 0, resizeHeight: Int = 0) throws -> Data {
