You could also give all the images an id= attribute, and fill them in using javascript afterwards. But it won't make your page faster, just slower.
Some php configurations secretely do an ob_start(). You could try to put a ob_end_flush(); at the beginning of your script.