Contributions from grain surface and gas phase chemistry to the formation of methyl formate and its structural isomers