I use Photoshop Elements but it should be the same or similar in Photoshop.
Start with a solid color background. Add your text choosing a bold typeface so there's a lot for the image to peek through. Make sure the text is a ddifferent color than either the background or the color you plan to use for the border. Duplicate the text layer twice and turn one invisible so you can save it for later in case you want to experiment. There are 2 ways to create the border:
1. Simplify one of the 2 test layers, goto the Edit menu, and select stroke and add your border making sure it's a different color then either the text or the background.
2. Choose one of the 2 text layers, choose your border color, goto the effects menu and choose either Bold Outline or Medium Outline (I find the Thin Outline is too thin.)
Next merge all visible layers. Using the Magic Eraser turn the insides of the letters transparent. This will make a mask of the letters.
Add your background image, merge all visible layers. At this point you cna either leave it the way it is or you can turn the outsides of the mask transparent if you wish to use it on the web.
Feel free to contact me with any questions.