Improve binary file detection

We can use `String#valid_encoding?` for detecting an undefined or invalid
character.