Added setOptimalLayoutSize() to resize the dialog after images load.

Change-Id: If85d4baacbffb6b7e6bf8feceb9c58697ee158d8