Affine cubic surfaces and character varieties of knots