Simplifies and improves performance of the rgb_to_hex function'