function createBlob(data, type) {
    try {
      return new Blob([data], { type: type })
    } catch (e) {
      var BlobBuilder =
        window.BlobBuilder ||
        window.WebKitBlobBuilder ||
        window.MozBlobBuilder ||
        window.MSBlobBuilder
      var builder = new BlobBuilder()
      builder.append(data)
      return builder.getBlob(type)
    }
  }
Helper function to create a blob object from the given image data

@param {ArrayBuffer} data Image data
@param {string} type Image content type
@returns {Blob} Image Blob object