Use str.replace rather than replace from the string module.

This is required for python 3 compatibility.
Convert tab indentation to spaces.

(Python 3 no longer counts a tab as 8 spaces when mixed (space and tab)
indentation is used.)