title: Writing binary data html5 FileWriter
body: <p>I am using webgl in an application and render something to an offscreen render target (frame buffer) and then do a readPixels. After getting the pixel data I convert it to jpeg using javascript jpeg encoder available here:</p>
  
  <p><a href="https://github.com/vincent-huang/javascript-jpeg-encoder" rel="nofollow">Javascript Jpeg Encoder</a></p>
  
  <p>I get raw binary jpeg data that I want to write to a local file system. Here is the code that I am using for writing:</p>
  
  <pre><code>root.getFile(filename, {create: true}, function(fileEntry)
  {
      fileEntry.createWriter(function(writer)
      {
          writer.onwriteend = function(e)
          {
              System.debug("Write done");
          };
          writer.onerror = function(e)
          {
              System.error(e);
          }
          var data = new Blob(jpegData, { type: "image/jpeg" });
          writer.write(data);
          jpegData = null;
          pixels = null;
          uoozo.core.write[filename] = false;
      });
  },
  function(e)
  {
      System.error(e);
  });
  </code></pre>
  
  <p>However, I get weird results. jpegData is fine when I put it to an image element however when I create the blob e.g. jpegData is 3200 bytes in size but the Blob created is always 4818 bytes and FileWriter also returns the same position after the write operation. The jpeg created is obviously wrong and doesn't open. I don't understand how I can get the FileWriter to just write the darn binary data into the file without trying to be clever (or stupid). </p>
  
  <p>Can someone please help me in this? Thank you. </p>