Instead of using `IFEXIST` you can do
```python
val = d.get(attrib, '').encode('utf-8')
```