Download file, allow cookies

Hi, well, when i download an image from a site, instead of download
the required image it downloads an image which says “Allow Cookies”.
How can i download that image?
This is what i was using

writeOut = open(first_page.to_s + “.”+extension, “wb”)
writeOut.write(open(img_to_download).read)
writeOut.close