Cook onion and chiles in 3 tablespoons butter in a 10-inch heavy skillet over moderate heat, stirring occasionally, until well softened, 5 to 7 minutes. Stir in huitlacoche, salt, and pepper. Reduce heat to low and cook, stirring frequently, until almost all of liquid is evaporated (if using fresh or thawed frozen, cook until mixture is aromatic and wilted), 3 to 7 minutes.