Preheat the oven to 400°F (200°C). Line a baking sheet with parchment paper.
Heat the olive oil in a skillet over medium-high heat.
Add the onion and cook for 3 to 4 minutes until softened.
Stir in the garlic and cook for 30 seconds.
Add the ground beef and cook until browned, breaking it into small crumbles.
Drain any excess grease.
Sprinkle in the taco seasoning and add the water. Stir until the beef is evenly coated.
Mix in the corn and diced tomatoes. Cook for another 2 minutes.
Remove from the heat and let the filling cool slightly.
Roll out the puff pastry and cut it into 4 equal rectangles.
Place the beef mixture in the center of each rectangle.
Top with shredded cheddar cheese and green onions.
Fold the pastry over the filling and seal the edges with a fork.
Transfer the pockets to the prepared baking sheet.
Brush the tops with beaten egg.
Bake for 20 to 25 minutes, or until golden brown and puffed.
Brush with melted butter if desired and let cool for 5 minutes before serving.