code: function(name) {
    var screenshot = page.renderBase64('PNG');
    screenshot = 'data:image/png;charset=utf-8;base64,'+screenshot;
    // send the data into node.js by going via JS and over HTTP
    page.evaluate(function(data, n) {
      window.jsJobEvent('screenshot', { name: n, data: data });
    }, screenshot, name);
  }
docs: Screenshots