Fix for line toObject method.

Calculate line points when we need to serialize it.
Also correctly flip line when resizing it.

Fix #1396 #744