Fix casting to bytes