Assuming you know how to do the I/O, I presume your're stuck on the logistics.

Let's say your base name is foo. Create your clumps in foo_1.jpg, ... foo_n.jpg. When you tell your unsplitter the base name, it'll look for all the foo_*.jpg files and glue them back together.

Now, that's an acceptable method if you can be sure that all of the files are present. If you can't be sure that all the pieces are there, create a foo_0.jpg that tells the unsplitter what files belong in the set. Note that with that method, your file names need not follow any particular pattern.