correction bug for images where width is not a multiple of 4 or 8