For your purposes (writing the file) the field is an eight-digit string, so treat it as such, and only use the date conversions as an intermediate step to producing an eight-digit string.
So something like this (pseudocode):
if date field is null
{
return "00000000"
}
else
{
return string of date formatted as "MMddyyyy"
}