Until the Second World War, the Sofrim accomplished this effect by writing the famous "broken Peh", which ensures that the inner Bet is always visible (click here for my post on the Broken Peh). You can see it here in one of my manuscripts:
Nowadays, the Ashkenazi sofrim use a more "modern" Peh that also has the inner Bet:
What's this mysterious inner Bet?
The Talmud says that the Torah was given with Black Fire and White Fire, and the Kabalists give many different explanations to this concept.
Rabbi Menachem MiPanu, one of the leading Kabbalists of the 16th century explains that the letters of the Torah are the Black Fire, which is easily visible. The White Fire is more difficult to see - it's the empty parchement of the Torah, which includes the gaps (open and closed Parshiot), the Sirtut (guiding lines) and contour of the black letters, like the Peh's inner Bet.
The letter Peh has "heavy" connotation - it's symbolizes "din", judgment. In Hebrew, the Peh is written like this: פא, which can also be read as אף, a symbol of G-d's wrath in Jewish tradition.
That's the reason why the Kabbalists introduced the inner Bet; Bet is the symbol of kindness and blessing (see previous post - that's why G-d created the world with the letter Bet) and it is a counterweight to the "strictness" of the letter Peh.
Other letters (shin, aleph to name a few) also have this interplay between the "White" and "Black" fires but the Peh is the most famous example.