code: function dataURItoBlob(dataURI) {
      // convert base64 to raw binary data held in a string
      var byteString = atob(dataURI.split(',')[1]),
          // separate out the mime component
          mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0],
          // write the bytes of the string to an ArrayBuffer
          arrayBuffer = new ArrayBuffer(byteString.length),
          _ia = new Uint8Array(arrayBuffer),
          i, dataView, blob;
  
      for (i = 0; i < byteString.length; i++) {
          _ia[i] = byteString.charCodeAt(i);
      }
  
      dataView = new DataView(arrayBuffer);
      blob = new Blob([dataView], { type: mimeString });
  
      return blob;
  }
docs: https://gist.github.com/davoclavo/4424731