Peru's President Martin Vizcarra has managed to stave off a political crisis. Lawmakers have agreed to a referendum in October.