Attach New Brace to Joists for Ceiling Fan
When I have attic access and need to add an electrical box for a fan or light I use two pieces of wood. One is made long enough so that it lays flat across the tops of the ceiling joists. The second piece is made to mount under the first piece but be on edge. Typically this second piece needs to be cut for width so that its bottom edge comes right at the level where the top of the electrical box needs to be located. Both pieces are cut from 1.5 inch thick framing lumber. The top flat piece is screwed down through the top ends into the tops of the ceiling joists. The other "on edge" piece is screwed to the top piece down from the top of the flat piece. The screws that hold these pieces in place should be respectable size and length screws installed through clearance holes and into pilot holes. For 1.5 inch thick lumber I typically use 3.5" #10 size screws. 

This makes for a very sturdy mount for an electrical box even for fan mounts.

There is another significant advantage to this approach. It does not put sidewise pressure or pounding on to the ceiling joists. Such pounding and pressure can cause blistering of drywall finish on the ceiling where screws or nails are holding up the ceiling drywall.