[ruby & win xp] Captha problem

Hello, I have created small application which has to log me in onto
forum. Login form has also php generated token. Im using hpricot &
mechanize & captha to hadle this form. My problem is: when captha
download token to my hdd, i cannot open it and read letters from image.
I encouter info dialog that png image is broken and unreadable.

my code, to hadle token download:

captha_image = quest_get(CAPTHAURL + rand.to_s)

captha_file = File.open(“captha.png”, ‘w’)
captha_file.write captha_image.body
captha_file.close

thank You for interesting - any idea how to solve this one?
Kyle