One way to do this is to get your self the live CD version of GParted.
http://gparted.sourceforge.net/livecd.php
which you may find comes in very useful for other jobs as well in the future.
So what you do is:
1) Get a 16GB card and write your 8GB image to it.
2) Make sure it boots on a Pi but do not resize the filesystem to use 16GB
3) Back on the PC boot it with the GParted live CD and put the 16GB SD into your card reader.
4) Use Gparted to shrink the root file system down to something a bit smaller, that will fit on your 8GB cards.
5) Now you can get back to your normal OS and copy the SD image to a file as you have done before.
6) Use that image file to create all your new 8GB SD cards.
Memory in C++ is a leaky abstraction .