diff --git a/src/common/exceptions.py b/src/common/exceptions.py
index 52c08b6310bc3d8953bd3f4e8bdb1fc8d8884ac3..f91f600a3990b34d4b108b62b3e4e8857bb44e6e 100644
--- a/src/common/exceptions.py
+++ b/src/common/exceptions.py
@@ -82,6 +82,15 @@ class Cancelled(Exception):
 	'''The user cancelled an operation'''
 	pass
 
+class LatexError(Exception):
+	'''sqlite2 raised pysqlite2.dbapi2.OperationalError'''
+	def __init__(self, text=''):
+		Exception.__init__(self)
+		self.text = text
+
+	def __str__(self):
+		return self.text
+
 class GajimGeneralException(Exception):
 	'''This exception is our general exception'''
 	def __init__(self, text=''):
diff --git a/src/conversation_textview.py b/src/conversation_textview.py
index f5e3396e5d211cbfdc62af9183d80122dc3a2856..eb23a7ec4c8bace91cc558d6a565e036576fa39d 100644
--- a/src/conversation_textview.py
+++ b/src/conversation_textview.py
@@ -50,6 +50,7 @@ from common.fuzzyclock import FuzzyClock
 
 from htmltextview import HtmlTextView
 from common.exceptions import GajimGeneralException
+from common.exceptions import LatexError
 
 NOT_SHOWN = 0
 ALREADY_RECEIVED = 1
@@ -964,16 +965,27 @@ class ConversationTextview:
 			file.flush()
 			file.close()
 
-			p = Popen(['latex', '--interaction=nonstopmode', tmpfile + '.tex'],
-				cwd=gettempdir())
-			exitcode = p.wait()
+			try:
+				p = Popen(['latex', '--interaction=nonstopmode', tmpfile + '.tex'],
+					cwd=gettempdir())
+				exitcode = p.wait()
+			except Exception, e:
+				exitcode = _('Error executing "%(command)s": %(error)s') % {
+					'command': 'latex --interaction=nonstopmode %s.tex' % tmpfile,
+					'error': str(e)}
 
 		if exitcode == 0:
 			latex_png_dpi = gajim.config.get('latex_png_dpi')
-			p = Popen(['dvipng', '-bg', 'white', '-T', 'tight', '-D',
-				latex_png_dpi, tmpfile + '.dvi', '-o', tmpfile + '.png'],
-				cwd=gettempdir())
-			exitcode = p.wait()
+			try:
+				p = Popen(['dvipng', '-bg', 'rgb 1.0 1.0 1.0', '-T', 'tight', '-D',
+					latex_png_dpi, tmpfile + '.dvi', '-o', tmpfile + '.png'],
+					cwd=gettempdir())
+				exitcode = p.wait()
+			except Exception, e:
+				exitcode = _('Error executing "%(command)s": %(error)s') % {
+					'command': 'dvipng -bg rgb 1.0 1.0 1.0 -T tight -D %s %s.dvi -o %s.png' %\
+						(latex_png_dpi, tmpfile, tmpfile),
+					'error': str(e)}
 
 		extensions = ['.tex', '.log', '.aux', '.dvi']
 		for ext in extensions:
@@ -982,6 +994,9 @@ class ConversationTextview:
 			except Exception:
 				pass
 
+		if isinstance(exitcode, (unicode, str)):
+			raise LatexError(exitcode)
+
 		if exitcode == 0:
 			result = tmpfile + '.png'
 
@@ -1076,7 +1091,12 @@ class ConversationTextview:
 				if not show_ascii_formatting_chars:
 					special_text = special_text[1:-1] # remove _ _
 		elif special_text.startswith('$$') and special_text.endswith('$$'):
-			imagepath = self.latex_to_image(special_text)
+			try:
+				imagepath = self.latex_to_image(special_text)
+			except LatexError, e:
+				# print the error after the line has been written
+				gobject.idle_add(self.print_conversation_line, str(e), '', 'info', '', None)
+				imagepath = None
 			end_iter = buffer.get_end_iter()
 			anchor = buffer.create_child_anchor(end_iter)
 			if imagepath is not None: