Works fine here, maybe you should send how you do read your file

[~/tmp]% cat test_read.rb
data = File.open(ARGV[0]) do |file|
    file.read
end
puts data.inspect

[~/tmp]% echo -n '\000\000\000\001' > file
[~/tmp]% ruby test_read.rb file
"\000\000\000\001"

Regards,
Sylvain Joyeux