function canvasToBlob(canvas, type, quality) {
        if (typeof canvas.toBlob === 'function') {
            return new Promise(function (resolve) {
                canvas.toBlob(resolve, type, quality);
            });
        }
        return Promise.resolve(dataURLToBlob(canvas.toDataURL(type, quality)));
    }
Convert a <code>canvas</code> to a <code>Blob</code>.

Examples:

```js
blobUtil.canvasToBlob(canvas).then(function (blob) {
  // success
}).catch(function (err) {
  // error
});
```

Most browsers support converting a canvas to both `'image/png'` and `'image/jpeg'`. You may
also want to try `'image/webp'`, which will work in some browsers like Chrome (and in other browsers, will just fall back to `'image/png'`):

```js
blobUtil.canvasToBlob(canvas, 'image/webp').then(function (blob) {
  // success
}).catch(function (err) {
  // error
});
```

@param canvas - HTMLCanvasElement
@param type - the content type (optional, defaults to 'image/png')
@param quality - a number between 0 and 1 indicating image quality
                                    if the requested type is 'image/jpeg' or 'image/webp'
@returns Promise that resolves with the <code>Blob</code>