C language reading and writing of BMP images and operations on pixels