           op.fail(df.reject, release)
           op.done (canvas) ->
             # start = new Date()
-            utils.canvasToBlob canvas, 'image/jpeg', settings.quality or 0.8,
+            format = 'image/jpeg'
+            quality = settings.quality or 0.8
+            if not isJPEG and ns.hasTransparency(canvas)
+              format = 'image/png'
+              quality = undefined
+            utils.canvasToBlob canvas, format, quality,
               (blob) ->
                 canvas.width = 1
                 canvas.height = 1

      df.resolve(new Blob(newChunks, {type: blob.type}))

    df.promise()

        df.notify(.1)

        # start = new Date()
        isJPEG = op.state() is 'resolved'
        img = new Image()
        img.onload = ->
          # console.log('load: ' + (new Date() - start))
