Encode doesn't always returns ok