It's probably done in the CSS, but if you want to do something with a "count of three" in the PHP, you can just use a counter and increment it each time, then you know which image you're on in the while(next_image()): loop.
But it's much easier to just put them each in a DIV and make the widths so they fall into three columns. Much much easier and more elegant. I recommend that.