Add fopen timeout so that invalid image URLs don't hang.
Add isValid method to check whether a stream to the image URL was successfully opened.