Self-written http code to download images from url