How to insulate around a brick basement window?
Normally, windows are installed into masonry with a wooden "buck", a frame wrapping all sides with treated lumber. (See photos #1 and #2.) This is bolted and sealed to the concrete or brick. The window is installed inside the buck with a small gap, which is itself insulated and sealed, and a finished extension jamb is installed to the interior of the window frame where necessary. 

In your case, the best you can do is seal all gaps with more spray foam. I'd mask the entire window with tape, then spray the brick face with thin layers. Wait until the foam expands, then add more if needed. 

The gap at the top of the photo needs to be addressed, too. I'd probably fill i with fiberglass batt insulation. Stuff it loosely, but completely full. I'd need better photos of that area to offer more advice.