New RGB <-> HSV conversion routines

The old ones were buggy