Encoding error when trying to write file

[Rails 3 - Ruby 1.9.2]

I have to get email attachments ( mp4 files ) and store them…
I get easily all parts using Mail ( … <Content-Type: multipart/
mixed…"> )

    attachment  = mail.attachments[0]
    #<Mail::Part:2206885940, Multipart: false, Headers: <Content-

Type: video/mp4; name=landscape.mp4>, <Content-Transfer-Encoding:
base64>, <Content-Disposition: attachment; filename=landscape.mp4>>
got what I need,

but trying to store this attachment in a temp file , I get an encoding
error :

 File.open(filepath,File::CREAT|File::TRUNC|File::WRONLY,0644) { |

f| f.write(attachment.body) }

   Encoding::UndefinedConversionError Exception: "\x80" from

ASCII-8BIT to UTF-8

did I miss anything before writing the file ? or is it a known Ruby
bug ?
being an .mp4 attachment, it should be a binary file… it comes as an
UTF-8 ( Base64) ? , right…
how should I write it as a binary too ?

tfyh