Don't use fprintf to output D strings since they might contain embedded nulls.

Instead, use fwrite to output the string in its entirety. It's probably
more efficient this way anyway, since we bypass format string parsing in
fprintf.
Update unittest to check for correct writing of embedded nulls.