Change most statics to consts

Only TEST_DATA is left as a static value for testing lifetime.
Restore the typecast in mode_from_kind_and_perm

This reverts commit 39e78dab8fe8269dd8abedc2f9fcf22c131f2f05, because
some platforms like MacOS have "mode_t = u16" and really do need the
typecast.  Added #[allow(unnecessary_typecast)] with a comment instead,
so Linux with "mode_t = u32" doesn't get a warning.
from_utf8_lossy -> from_utf8