Former teacher pleads guilty to sex crimes