This was quite useful. If you set up a git repo for this, I'd be happy to pull request along some of my additions. In my version I needed bigger cubes so I rewrote your recursive implementation of floodfill to use a loop and a queue to speed up performance and allow it to go past the limits of the C stack for size (I was capping at about 30x30x30 pixels).