What would be the best way to fill "space" in user interface for irregular image sizes gallery?

Conditions:

* The row are subjected to hold maximum 3 images only.
* Float left
* If the total width of the images exceed the width of container, the images will shift and create a space.

![Irregular Images with space](https://i.stack.imgur.com/CWPbDm.png)

For example: 

I am concerned with the red box (they are empty spaces).

**How to make my gallery empty space filled up, as I do not want the empty spaces to create an unattractive interface?**