Tesla to build Shanghai factory to make Megapack batteries