added gridInfoFile as a parameter
fixed more type errors and added the writedlm3D function for writing 3D arrays