Improve exception and error message when trying to write mixed-mode assemblies. Fix #131