add timeout to download image & refactoring.
Merge commit 'a892da9c55e8160237e871a337fc20bf38a34825' into HEAD