[libcontacts] Move photo handling logic into libcontacts