The optimal population size under pollution and migration externalities: a spatial control approach