Optimize open and close operations

Do not take the unnecessary step of copying original pixels.