properly serializing nested file objects