Primordial magnetic fields from self-ordering scalar fields