In a small sauce pan, whisk together flour, sugar and (optional) espresso powder. Pour in milk, then turn heat on medium-low. Cook until a thick paste forms. Check the temperature with a food thermometer; should be around 160-165F for cooked flour.
Remove from heat, and allow to cool to room temperature. If it is cold outside, place on the porch to speed up cooling.
Meanwhile, in a medium mixing bowl, use hand mixer or stand mixer to whip the butter and cocoa powder for 3-5 minutes (can use paddle attachment or standard beaters for hand mixer)
Add cooled milk-flour mixture and cream for another 5-8 minutes.
Lastly add in vanilla and optional powdered sugar if you prefer it more sweet. Mix about 1-2 minutes until fully combined and frosting is smooth.