fixed a bug in demosaic