Make a vertically-flipped copy of a buffer or image.
@param {external:canvas|external:image} buffer The original image
@return {external:canvas} The flipped buffer
function flipBufferVertically(buffer) {
  return makeBuffer(buffer.width, buffer.height, function(context) {
    context.scale(1, -1);
    context.drawImage(buffer, 0, -buffer.height);
  });
}