Image not divisable by 8? (JPEG Compression)
Then it's size is extended by padding zeros or repeating at the end, such that the new size is divisible by 8. Note that reverse repetition at the end reduces the DCT compression size on that block compared to a zero pad approach.

For example if the image was 29 x 27 , then you should add 3 pixels at the right end and 5 lines at the bottom so that it becomes 32 x 32.

Note that you should include the pixel size of the image in the header part so that during decoding process you create the true sized image as 29 x 32