copyGray is more robust by accounting for different image types