refactored imagedownload (added timeout, prevent overrun of maxsockets)