Fixed bug in OutputContours.

This seems to be a bug. When using ElementType.BoundaryContours the bug lead to crashes every time. This seems to fix it.

I've isolated this one into a branch so you can merge it more easily, but my master branch has a handful more changes which might be interesting nevertheless.

Thanks!