While we think of an image as pixels and lines, i.e., a two dimensional array like a checkerboard, the data is stored in the file as a single linear string of data. Adding the padding all at once would either write it all in one place, probably at the end, would overwrite image data and leave a corrupted file, or would require a complicated process that would require writing each padding separately, defeating the goal of writing all at once.
If I understand your question, it seems like you want to add all the padding after processing the image data. To do so, you'd have to insert the padding between "rows of pixels" or more accurately, into the interior of the string of data at the correct locations. While theoretically possible, it would be very complicated by comparison and prone to errors. To do this, you'd be repeating most of the process that you've just done and that which you'd have to do to add the padding as you went along anyways.
It is far simpler and easier to just insert the padding as you go.
If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)