decode_base64 = function(base64) {
        var len = base64.length,
            buffer = new Uint8Array(len / 4 * 3 | 0),
            i = 0,
            outptr = 0,
            last = [0, 0],
            state = 0,
            save = 0;

        while (len--) {
          var code = base64.charCodeAt(i++);
          var rank = base64_ranks[code - 43];
          if (rank !== 255 && rank !== undefined) {
            last[1] = last[0];
            last[0] = code;
            save = (save << 6) | rank;
            state++;
            if (state === 4) {
              buffer[outptr++] = save >>> 16;
              if (last[1] !== 61 /* padding character */) {
                buffer[outptr++] = save >>> 8;
              }
              if (last[0] !== 61 /* padding character */) {
                buffer[outptr++] = save;
              }
              state = 0;
            }
          }
        }
        // 2/3 chance there's going to be some null bytes at the end, but that
        // doesn't really matter with most image formats.
        // If it somehow matters for you, truncate the buffer up outptr.
        return buffer.buffer;
      }
@fileoverview Serves for extended saving of canvas content as png.

@author petr.sloup@klokantech.com (Petr Sloup)