Add a newline after an ImageSpan is inserted, if needed.

Moved image processing to its own method.