Fixed so saveAs and toBuffer can be called multiple times.