improve various error handling issues for file encoding
fix text/bytes mode for some file injectors