cleaned up and optimized rgb2bayer