Many-body effects in x-ray photoemission from magnesium