Solved problem when the width of images is not divisible by 4.