A p-adic non-abelian criterion for good reduction of curves