Merge the encoder/decoder crt_util_safe_x.h into the common lib

Later this allows using the smarter wrappers (previously from the decoder) in the encoder, getting rid of a whole lot of code in the ifdefs around FOPEN and SNPRINTF.