docs: function writeStream(filename, st) {
      var d = Promise.defer();
  
      var wstream = fs.createWriteStream(filename);
      var cleanup = function() {
          destroy(wstream);
          wstream.removeAllListeners();
      };
  
      wstream.on('finish', function () {
          cleanup();
          d.resolve();
      });
      wstream.on('error', function (err) {
          cleanup();
          d.reject(err);
      });
  
      st.on('error', function(err) {
          cleanup();
          d.reject(err);
      });
  
      st.pipe(wstream);
  
      return d.promise;
  }