Fix some crashes.
Fix some crashes.

attributesAtIndex:effectiveRange: can crash if index is out of bounds, this can happen if somehow we're inserting images into a 0 length string.
addAttribute:value:range: can crash if value is nil
bogardon/nimbus,bogardon/nimbus,bogardon/nimbus,bogardon/nimbus,bogardon/nimbus,bogardon/nimbus,bogardon/nimbus