Add support for RGBA and two new modes: im1, im2
Use the smaller size of imaegs preventing the code from exception of index-of-range
Refine the code