Fix an encoding problem for running ViewHtmlAction

- Add null checking for FileObject
- Check encoding for FileObject if ViewHtmlOnSave is enabled