Added IO timeouts to prevent threads hanging indefinitely.
Give priority to larger images.