add flip function, fixed RGB channels