title: how to save canvas data to file
body: <p>i am using node.js to save canvas to image 
  img in writeFile is extractedby using toDataURL on my canvas element.
  it doenot save file
  here is my code</p>
  
  <pre><code>var fs = IMPORTS.require('fs');
  var path = IMPORTS.require('path');
  path.exists('images/', function(exists){
      if (exists) {
  
          fs.writeFile('images/icon.png', img, function(err){
              if (err) 
                  callback({
                      error: false,
                      reply: err
                  });
              console.log('Resized and saved in');
              callback({
                  error: false,
                  reply: 'success.'
              });
          });
      }
      else {
          callback({
              error: true,
              reply: 'File did not exist.'
          });
      }
   });    
  </code></pre>