Preventing files from being changed
You can do it using chflags. Try this way:

chflags uchg filename


Once type this command, filename can only be modified by you. Others users (root included) can't change it.

To revert the changes, use:

chflags nouchg filename


See the example below:

✔ jherran@computer: ~/temp $ touch filename
✔ jherran@computer: ~/temp $ chflags uchg filename
✔ jherran@computer: ~/temp $ sudo su
Password:
✔ root@computer: /Users/jherran/temp # rm filename
rm: cannot remove ‘filename’: Operation not permitted
✘-1 root@computer: /Users/jherran/temp # rm -f filename
rm: cannot remove ‘filename’: Operation not permitted
✘-1 root@computer: /Users/jherran/temp #