Fix illegal filename characters write exceptions.

Just remove the illegal marks from the filename. If that leaves the
filename empty replace it with APP