SOLUTION: there were extra whitespaces in the functions.php file. After removing these it solved the issue.
Reference links:
http://kb.yoast.com/article/58-xml-sitemap-error
https://wordpress.org/support/topic/error-on-line-3-at-column-6-xml-declaration-allowed-only-at-the-start-of-the-do-2