Write a swap function for an mp_image, construct the downsampled image into a temporary mp_image and swap it with dest_image before returning.
Can't get much better than that!
void swap(mp_image &other)
mp_image& DownsampleNTimes(int n, mp_image& dest_image)
mp_image temp(w/n, h/n); /* Initialize dest_image here with width w/n and height h/n */
/* more code... */
Using a vector and following the rule of three could also help.