func cloneImage(i *image.RGBA) *image.RGBA { i2 := new(image.RGBA) *i2 = *i i2.Pix = make([]uint8, len(i.Pix)) copy(i2.Pix, i.Pix) return i2 }