To prevent the cheese from melting out, make sure to seal the edges of the cordon bleu properly. You can also use toothpicks to secure the filling inside.