Is modifying a box unsafe or against any electrical codes?
The box you used is slightly smaller (20 cu.in. vs. 21.5 cu.in.), but that won't matter as long as you still comply with the box fill rules.  It also doesn't appear to be labeled for fan support, which means it can only support a fan up to 35 lbs. Aside from those issues, I'd say there's no problem with what you did.