encode: move img_dump_padded out of encode_img_in